VERSION 1.0 CLASS
BEGIN
  MultiUse = -1  'True
  Persistable = 0  'NotPersistable
  DataBindingBehavior = 0  'vbNone
  DataSourceBehavior  = 0  'vbNone
  MTSTransactionMode  = 0  'NotAnMTSObject
END
Attribute VB_Name = "RainbowPulser"
Attribute VB_GlobalNameSpace = False
Attribute VB_Creatable = True
Attribute VB_PredeclaredId = False
Attribute VB_Exposed = False
Option Explicit

'TODO: Insert standard header

' From Acorn!!! :)

Private m_Form As Form

'#Region Public Properties

Public Property Get Form() As Form
    Set Form = m_Form
End Property

Public Property Set Form(ByVal oNewValue As Form)
    Set m_Form = oNewValue
End Property

'#End Region

'#Region Public Methods

' Summary:
'   Sets the background of the form to the next value in the cycle.
Public Sub Pulse()
    Dim IncreaseRed   As Boolean
    Dim IncreaseBlue  As Boolean
    Dim IncreaseGreen As Boolean
    Dim DecreaseRed   As Boolean
    Dim DecreaseBlue  As Boolean
    Dim DecreaseGreen As Boolean
    
    Static Current    As Long
    
    'i R G B
    'd R G B
    
    'i R B G
    'd R B G
    
    'i G R B
    'd G R B
    
    'i G B R
    'd G B R
    
    'i B R G
    'd B R G
    
    'i B G R
    'd B G R
    
    Select Case Current
        Case 0:  IncreaseRed = True
        Case 1:  IncreaseGreen = True
        Case 2:  IncreaseBlue = True
        Case 3:  DecreaseRed = True
        Case 4:  DecreaseGreen = True
        Case 5:  DecreaseBlue = True
        
        Case 6:  IncreaseRed = True
        Case 7:  IncreaseBlue = True
        Case 8:  IncreaseGreen = True
        Case 9:  DecreaseRed = True
        Case 10: DecreaseBlue = True
        Case 11: DecreaseGreen = True
        
        Case 12: IncreaseGreen = True
        Case 13: IncreaseRed = True
        Case 14: IncreaseBlue = True
        Case 15: DecreaseGreen = True
        Case 16: DecreaseRed = True
        Case 17: DecreaseBlue = True
        
        Case 18: IncreaseGreen = True
        Case 19: IncreaseBlue = True
        Case 20: IncreaseRed = True
        Case 21: DecreaseGreen = True
        Case 22: DecreaseBlue = True
        Case 23: DecreaseRed = True
        
        Case 24: IncreaseBlue = True
        Case 25: IncreaseRed = True
        Case 26: IncreaseGreen = True
        Case 27: DecreaseBlue = True
        Case 28: DecreaseRed = True
        Case 29: DecreaseGreen = True
        
        Case 30: IncreaseBlue = True
        Case 31: IncreaseGreen = True
        Case 32: IncreaseRed = True
        Case 33: DecreaseBlue = True
        Case 34: DecreaseGreen = True
        Case 35: DecreaseRed = True
    End Select
    
    ' Obtain the current colours from the form
    Dim Red As Byte, Green As Byte, Blue As Byte
    Call Colour.Long2RGB(Me.Form.BackColor, Red, Green, Blue)
    
    If IncreaseRed = True Then
        If Red < 255 Then
            Red = Red + 1
          Else
            Current = Current + 1
        End If
    End If
    
    If IncreaseGreen = True Then
        If Green < 255 Then
            Green = Green + 1
          Else
            Current = Current + 1
        End If
    End If
    
    If IncreaseBlue = True Then
       If Blue < 255 Then
            Blue = Blue + 1
          Else
            Current = Current + 1
        End If
    End If
    
    If DecreaseRed = True Then
        If Red > 0 Then
            Red = Red - 1
          Else
            Current = Current + 1
        End If
    End If
    
    If DecreaseGreen = True Then
        If Green > 0 Then
            Green = Green - 1
          Else
            Current = Current + 1
        End If
    End If
    
    If DecreaseBlue = True Then
        If Blue > 0 Then
            Blue = Blue - 1
          Else
            Current = Current + 1
        End If
    End If
    
    If Current > 35 Then Current = 0
    
    'Debug.Print "RGB(" & CStr(r) & ", " & CStr(g) & ", " & CStr(b); ")"
    Dim NewBackColour As Long
    NewBackColour = Colour.RGB2Long(Red, Green, Blue)
    Me.Form.BackColor = NewBackColour
End Sub

'#End Region
